using Godot;
using System;

public partial class BTComposite : BTNode//复合节点，包括选择、顺序等节点，不执行命令
{
	public int _index_child_node = 0;
	private BTNode next_node;
	public override void _Ready()
	{
		if(this.GetChildCount() <= 0)
		{
			GD.Print("复合节点必须要有子节点");
			return;
		}
		foreach(BTNode c in GetChildren())
		{
			c.completed += On_child_completed;
		}
	}
	public virtual void On_child_completed(bool result)
	{
	}

	public bool Run_current_childnode()
	{
		if(_index_child_node >= GetChildCount())
		{
			_index_child_node = 0;
			return false;
		}
		else
		{
			
			next_node = GetChild<BTNode>(_index_child_node);
			next_node.run();
			return true;
		}
	}
}
